home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cmln1286.arc / BNCHMARK.ADA / CHAP3.ADA < prev    next >
Text File  |  1986-09-06  |  2KB  |  96 lines

  1. with TEXT_IO; use TEXT_IO;
  2.  
  3. procedure CHAPTER_3 is
  4.  
  5.     --
  6.     -- Selected tests from Chapter Three of the Ada LRM
  7.     --     Author: Bruce A. Bergman
  8.     --     Source available from Mark Petersen's Alpo-Net FIDO board at
  9.     --     (619) 741-3412, 300/1200/2400 8,N,1
  10.     --
  11.  
  12.  
  13.     --
  14.     -- enumeration types
  15.     --
  16.  
  17.     type COLOR is (white, red, yellow, green, blue, brown, black);
  18.     subtype RAINBOW is COLOR range red..blue;
  19.  
  20.     --
  21.     -- integer types
  22.     --
  23.  
  24.     subtype SMALL_INT is integer range -100..100;
  25.     subtype POS_INT is natural range 200..300;
  26.  
  27.     --
  28.     -- boolean types
  29.     --
  30.  
  31.     subtype FLAG is boolean;
  32.     type LIGHT_SWITCH is (on, off); -- can be mapped onto boolean
  33.                                     -- using representation specs.
  34.  
  35.     --
  36.     -- floating point types
  37.     --
  38.  
  39.     type REAL is digits 8;
  40.     subtype PROBABILITY is real range 0.0..1.0;
  41.  
  42.     --
  43.     -- fixed point types
  44.     --
  45.  
  46.     type VOLT is delta 0.125 range 0.0..5.0;
  47.     subtype ROUGH_VOLT is VOLT delta 1.0;
  48.  
  49.     --
  50.     -- array types
  51.     --
  52.  
  53.     type TABLE_TYPE is array (1..20) of natural;
  54.     type LARGE_TYPE is array (1..2) of table_type;
  55.  
  56.     --
  57.     -- record types
  58.     --
  59.  
  60.     type STATUS_TABLE is record
  61.         switch  : light_switch;
  62.         voltage : volt;
  63.     end record;
  64.  
  65.     type DISCRIM_RECORD(typ : color := red) is record
  66.         case typ is
  67.             when RED =>
  68.                 a : small_int;
  69.             when BLUE =>
  70.                 b : pos_int;
  71.             when others =>
  72.                 table : table_type;
  73.         end case;
  74.     end record;
  75.  
  76.     --
  77.     -- incomplete types
  78.     --
  79.  
  80.     type CELL; -- most used with access type; see below
  81.  
  82.     --
  83.     -- access types
  84.     --
  85.  
  86.     type LINK is access CELL;
  87.  
  88.     type CELL is record
  89.         a : integer;
  90.     end record;
  91.  
  92.  
  93. begin
  94.     null;
  95. end CHAPTER_3;
  96.